package com.by.facade.enums.information.sub;

import com.by.facade.enums.information.PromotionPlatformEventTypeEnum;
import com.by.facade.enums.information.PromotionPlatformTypeEnum;
import com.by.toolkit.utils.UrlUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Collections;
import java.util.Map;

/**
 * @author Tian Wei
 * @version 1.0
 * @date 2024/3/1 11:43 AM
 */
@Getter
@AllArgsConstructor
public enum JuLiangPromotionPlatformEventEnum {

    FORM("表单", Map.of("event_type", 3), PromotionPlatformEventTypeEnum.FORM.getType()),
    WX_CP_FRIEND_OPERATION("完成加V", Map.of("event_type", 386), PromotionPlatformEventTypeEnum.WX_CP_FRIEND_OPERATION.getType()),
    ;
    private final String desc;

    private final Map<String, Object> fixedParam;

    private final Integer promotionPlatformEventType;

    private static final StringBuilder BASE_PUSH_URL = new StringBuilder("https://ad.oceanengine.com/track/activate?link=");
    public static final String OK = "OK";

    public static JuLiangPromotionPlatformEventEnum resolveByPromotionPlatformEventType(Integer promotionPlatformEventType) {
        return (JuLiangPromotionPlatformEventEnum) PromotionPlatformTypeEnum.PROMOTION_PLATFORM_EVENT_TYPE_MAP.getOrDefault(PromotionPlatformTypeEnum.JU_LIANG.getType(), Collections.emptyMap()).get(promotionPlatformEventType);
    }

    public String generatePushUrl(String url) {
        StringBuilder append = BASE_PUSH_URL.append(url);
        return UrlUtil.httpUrlAppendParam(append.toString(), this.fixedParam, true);
    }
    public static Boolean checkResult(Map<String,Object> resultMap){
        return resultMap.values().contains(OK);
    }



}
